﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using MyBet.Helpers;
using MyBet.Class;
using MyBet.Web;

namespace MyBet
{
	public partial class UserInfo : UserControl
	{
        private SecurityServiceReference.UserObject _user;

        /// <summary>
        /// User to display
        /// </summary>
        public SecurityServiceReference.UserObject User
        {
            get { return _user; }
            set 
            { 
                _user = value;
                UpdateCulture();
            }
        }
		
		public UserInfo()
		{
			// Required to initialize variables
			InitializeComponent();
			UpdateCulture();
		}

        /// <summary>
        /// Update labels
        /// </summary>
        public void UpdateCulture()
        {
            if (App.CurrentUser != null)
            {
                lblLogin.Text = LangHelper.GetString("Login") + " : ";
                txtLogin.Text = App.CurrentUser.UserName;
                if (App.CurrentUser.Rank != 0)
                {
                    lblRank.Text = LangHelper.GetString("Rank") + " : ";
                    txtRank.Text = String.Format("{0}/{1}",App.CurrentUser.Rank.ToString(),App.CurrentUser.CustomContestPlayerCount) ;
                }
                else
                {
                    lblRank.Text = "";
                    txtRank.Text = "";
                }
                this.Visibility = Visibility.Visible;
            }
            else
            {
                this.Visibility = Visibility.Collapsed;
            }
        }
		
		
	}
	
}